<?php

/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: table_common_admincp_cmenu.php 27806 2012-02-15 03:20:46Z svn_project_zhangjie $
 */

if(!defined('IN_DISCUZ')) {
    exit('Access Denied');
}

class table_home_buyinfo extends discuz_table
{
    public function __construct() {

        $this->_table = 'home_buyinfo';
        $this->_pk    = 'id';

        parent::__construct();
    }

    public function get_record_count(){
        return DB::fetch_first("SELECT count(id) FROM %t WHERE del=0", array($this->_table));
    }

    public function get_all_record($start,$pageSize=10){
        return DB::fetch_all("SELECT * FROM %t b LEFT JOIN %t v ON b.v_id=v.v_id LEFT JOIN %t m ON b.m_id=m.uid WHERE b.del=0
          order by b.buy_time desc limit %d,%d", array($this->_table, 'home_video', 'common_member', $start, $pageSize));
    }

    public function get_record_by_id($id){
        return DB::fetch_first('select * from %t where id=%d and del=0',array($this->_table,$id));
    }

    public function del_record($id){
        return DB::query("UPDATE %t SET del=1 WHERE id=%d", array($this->_table,$id));
    }

    public function insert_record($data){
        return DB::query("INSERT INTO %t (v_id,m_id,buy_time,buy_type,del) VALUES(%d,%d,%s,%s,%d)",array($this->_table,$data['v_id'],$data['m_id'],$data['buy_time'],$data['buy_type'],$data['del']));
    }

}

?>